<template>
  <div class="home">
    <!-- 左侧菜单 -->
    <div class="slider" :class="{ fold: HomeSettingStore.fold ? true : false }">
      <Logo />
      <!-- 在固定区域内的滚动条 -->
      <el-scrollbar class="scrollbar">
        <!-- 滚动条内置菜单组件 -->
        <!-- :default-active="$route.path"页面加载时默认激活菜单的index -->
        <el-menu
          background-color="#001529"
          text-color="white"
          :default-active="$route.path"
          class="el-menu-vertical-demo"
          :collapse="HomeSettingStore.fold ? true : false"
        >
          <!-- 根据路由动态生成菜单 -->
          <Menu :menuList="userStore.menuRoutes"></Menu>
        </el-menu>
      </el-scrollbar>
    </div>
    <!-- 顶部导航区 -->
    <div class="tabbar">
      <Tabbar />
    </div>
    <!-- 内容展示区 -->
    <div class="main">
      <Main></Main>
    </div>
  </div>
</template>

<script lang="ts" setup name="Home">
import Logo from './logo/index.vue'
import Menu from './menu/index.vue'
import Tabbar from './tabbar/index.vue'
//引入用户相关的小仓库
import useUserStore from '@/store/modules/user'
import useHomeSettingStore from '@/store/setting'
//获取路由对象
import { useRoute } from 'vue-router'
import Main from './main/index.vue'
let HomeSettingStore = useHomeSettingStore()
let $route = useRoute()
const userStore = useUserStore()
</script>

<style scoped lang="scss">
.home {
  width: 100%;
  height: 100%;
  background: red;
  position: relative;

  .slider {
    position: fixed;
    left: 0;
    top: 0;
    width: $base-menu-width;
    height: 100%;
    background: $base-menu-background;
    //过渡动画
    transition: 0.3s all;
    .scrollbar {
      width: 100%;
      height: calc(100% - $base-menu-logo-height);
      // 隐藏右侧边框
      .el-menu {
        border-right: none;
        overflow: visible;
      }
    }
    &.fold {
      width: $base-menu-min-width;
    }
  }

  .tabbar {
    position: fixed;
    width: calc(100% - $base-menu-width);
    height: $base-tabbar-height;
    top: 0;
    left: $base-menu-width;
    transition: 0.3s all;
    &.fold {
      width: calc(100vw - $base-menu-min-width);
      left: $base-menu-min-width;
    }
  }

  .main {
    position: fixed;
    left: $base-menu-width;
    top: $base-tabbar-height;
    width: calc(100% - $base-menu-width);
    height: calc(100% - $base-tabbar-height);
    background: #f1f2f5;
    padding: 20px;
    overflow-y: auto; //滚动属性
    transition: all 0.3s;
    &.fold {
      width: calc(100vw - $base-menu-min-width);
      left: $base-menu-min-width;
    }
  }
}
</style>
